package net.pws.oos.web.mobile;

import net.pws.oos.biz.query.parameter.ProjectQueryParameter;
import net.pws.oos.web.ProjectAction;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/biz/mobile/project")
public class MobileProjectAction {
    
    @Autowired
    private ProjectAction projectAction;
    
    @RequestMapping("/count.json")
    @ResponseBody
    public Object getProjectCount(ProjectQueryParameter queryParams) {
        initQueryParams(queryParams);
        return projectAction.getProjectCount(queryParams);
    }
    
    @RequestMapping("/list.json")
    @ResponseBody
    public Object getProjectList(ProjectQueryParameter queryParams) {
        initQueryParams(queryParams);
        return projectAction.getProjectList(queryParams);
    }
    
    private ProjectQueryParameter initQueryParams(ProjectQueryParameter queryParams) {
        if (queryParams == null) {
            queryParams = new ProjectQueryParameter();
        }
        queryParams.setClose(Boolean.FALSE);
        return queryParams;
    }
    
}
